build: upgrade TypeScript to 7.0 - #56
Merged
Merged
Conversation
yCodeTech
force-pushed
the
build/upgrade-typescript
branch
from
August 26, 2026 06:34
97ece2a to
617d329
Compare
From Node v6, you have to explicitly include type modules, otherwise they will not be added globally to the project like `process` for Node, and module imports will error like `Cannot find name 'node:fs'`. - Added `types` array to tsconfig and included the `node` and `vscode` modules to fix import and usage errors. Ref: http://typescriptlang.org/tsconfig/#types
Fixed TS 7.0 errors by ensuring: - Variables don't have `undefined` or `null` values before accessing them and providing fallback values if they are undefined with the null coalescing operator (??) and conditional ternary operator (? .. : .. ). - Values from methods are satisfying their expected return types using the `as` keyword and generic typed method calls. - Object keys aren't accessed if the object itself is `undefined` with the optional chaining operator (?.) and proper undefined type guards and conditionals. - `reconstructRegex` util function infers the correct type from the passed `obj` param. - Error stack logging has a fallback of the error message in case the stack is null/undefined. - `convertMapToReversedObject` util function has properly typed `result` instead of implicit `any` type and changed the reverse object mapping to mutate the existing array instead of rebuilding a new one on every iteration.
- Changed type of `packageJsonData` property to allow it to be `null`. - Moved the null check from the `constructor` to the `setExtensionData` method, and use the check to narrow the type and assert that it's not null/falsy, and return early if it is. Using a local variable instead of accessing the property directly ensures TS doesn't keep spitting out null possibility errors.
yCodeTech
force-pushed
the
build/upgrade-typescript
branch
from
September 5, 2026 06:12
dc82707 to
3c36b06
Compare
…uctor. - Fixed the TS error "Property 'outputChannel' has no initializer and is not definitely assigned in the constructor." in Logger by adding a `constructor` and initialise the output channel inside it.
- Removed the now redundant `setupOutputChannel` Logger method and it's references, this is because the output channel is now setup in the `constructor` so we have no need for this method now. - Removed the redundant `outputChannel` property null check in `showChannel` method since it's never null as it's initialised in `constructor`.
There was a problem hiding this comment.
🟡 Changes recommended
Two moderate type-contract and error-fallback issues remain unresolved.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Upgrades the extension to TypeScript 7 and adapts types, nullability, and initialization behavior for compatibility.
Changes:
- Updates TypeScript and ECMAScript targets.
- Strengthens nullability, collection, and error-handling types.
- Initializes the singleton logger eagerly.
File summaries
| File | Description |
|---|---|
tsconfig.json |
Targets ES2025 and declares required types. |
src/utils.ts |
Tightens utility types; unmapped filesystem errors need the UNKNOWN fallback. |
src/logger.ts |
Initializes the output channel in the constructor. |
src/extensionData.ts |
Handles nullable package metadata. |
src/extension.ts |
Removes redundant logger setup. |
src/configuration.ts |
Adds nullability safeguards, but incorrectly makes the required editor edit optional. |
package.json |
Upgrades TypeScript to 7.0. |
Review details
- Files reviewed: 6/7 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Reverted the `edit` param in the `handleSingleLineBlock` Configuration method back to be required instead of optional because it otherwise insinuates the method can work without the `edit` param which is not true. It must have the param set to work. Also removed the optional chaining operator on the `edit.insert` call. The TS error that the optional operators fixed will return:
"Type '(textEditor: TextEditor, edit: TextEditorEdit) => void' is not assignable to type '(textEditor: TextEditor, edit?: TextEditorEdit | undefined) => void'.
Types of parameters 'edit' and 'edit' are incompatible.
Type 'TextEditorEdit | undefined' is not assignable to type 'TextEditorEdit'.
Type 'undefined' is not assignable to type 'TextEditorEdit'."
- Fixed the returning TS error above by making the `edit` param required instead of optional in the `handler` function in `CommandRegistration` interface, which the `handleSingleLineBlock` method has to satisfy.
If an error code was caught but isn't listed in the messages map, then the `errorMsg` in `validateDevEnvVariables` utils function would return something like "ENOTDIR: undefined: ...". - Fixed by adding a fallback to the `UKNOWN` entry when an error code is not mapped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request upgrades the TypeScript dependency to 7.0 and includes several improvements and refactorings aimed at increasing code safety, robustness, and maintainability, as well as fixing the new TS errors. The most notable changes are stricter null checks, improved type assertions, and the refactoring of the logger.
Dependency Updates:
typescriptdependency to version^7.0.0inpackage.json.TS Error Fixing:
Added nullish coalescing and optional chaining throughout
src/configuration.tsto prevent runtime errors fromundefinedornullvalues (e.g., when reading JSON files, accessing properties, or merging arrays).Improved type assertions and handling of possibly
undefinedvariables, especially in methods dealing with editor actions and configuration retrieval.Improved
nullsafety and early returns insrc/extensionData.tswhen reading and setting extension metadata, ensuring the extension does not attempt to use undefined package data.Refactored the logger in
src/logger.ts, moving output channel initialisation into theconstructorand removing the need for a separate setup method.